package com.xujl.mvcbind.window;

import android.app.Activity;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;

import razerdp.basepopup.BasePopupWindow;
import razerdp.blur.PopupBlurOption;

public abstract class BaseWindow extends BasePopupWindow {
    public BaseWindow (Context context) {
        super(context);
        Activity activity = getContext();
        if (activity == null) {
            return;
        }
        PopupBlurOption option = null;
        option = new PopupBlurOption();
        option.setFullScreen(true)
                .setBlurRadius(5f)
                .setBlurInDuration(-1)
                .setBlurOutDuration(-1);
        View decorView = activity.findViewById(android.R.id.content);
        if (decorView instanceof ViewGroup && decorView.getId() == android.R.id.content) {
            option.setBlurView(((ViewGroup) activity.getWindow().getDecorView()).getChildAt(0));
            option.setFullScreen(true);
        } else {
            option.setBlurView(decorView);
        }
        setBlurOption(option);
    }
}
